const {
	Controller
} = require('uni-cloud-router')
const uniID = require('uni-id')
module.exports = class UserController extends Controller {
	async addUser() {
		let result
		console.log(this.ctx.data)
		if(this.ctx.data.business){
			const {
				username,
				nickname,
				password,
				role,
				mobile,
				idCard,
				shopId,
				status
			} = this.ctx.data
			
			// result = await uniID.register({
			// 	username,
			// 	nickname,
			// 	password,
			// 	role,
			// 	mobile,
			// 	idCard,
			// 	shopId,
			// 	status
			// })
		}else{
			const {
				username,
				nickname,
				password,
				role,
				mobile,
				email,
				status
			} = this.ctx.data
			
			result = await uniID.register({
				username,
				nickname,
				password,
				role,
				mobile,
				email,
				status
			})
		}
		
		delete result.token
		delete result.tokenExpired

		return result
	}
	
	async resetPwd() {
		const {
			uid,
			password
		} = this.ctx.data
	
		const result = await uniID.resetPwd({
			uid,
			password
		})

		return result
	}
}
